package com.wm.config;

import com.wm.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @ClassName: MainConfig2
 * @Description: TODO
 * @Author: Deamer
 * @Date: 2022/9/26 21:51
 */
@Configuration
public class MainConfig2 {

    // 通过@Scope注解来指定该bean的作用范围，也可以说成是调整作用域
    @Lazy
    @Bean("person")
    public Person person() {
        System.out.println("给容器添加person对象");
        return new Person("wm", 28);
    }

    @Bean("bill")
    public Person person01() {
        return new Person("Bill Gates", 62);
    }

    @Bean("linus")
    public Person person02() {
        return new Person("linus", 50);
    }
}
